// index.js
// 获取应用实例
const app = getApp()
Page({
  data: {
    url: '',
    registerurl: 'https://www.e-cology.com.cn/mobilemode/mobile/view.html?appid=171&mTokenFrom=anonymous&mToken=510BEEE35CD3CC7B72AE0ECDEC97C818',
    registerShow: '',
    showYwgc: false,
    showBtn: false
  },
  /**
   * 返回首页
   */
  openhome() {
    wx.reLaunch({
      url: '/pages/index/index'
    })
  },
  /**
   * 打开客服咨询
   */
  openkfzx() {
    wx.openCustomerServiceChat({
      extInfo: {
        url: 'https://work.weixin.qq.com/kfid/kfcbb755e1fd954182d'
      },
      corpId: 'wx244a86711ee90e25',
      success(res) {
      },
      fail(res) {
      }
    })
  },

  // 打开业务阶段
  openyewujieduan() {
    wx.navigateTo({ url: `../businessPhase/index` });
  },

  openregister() {
    var url = encodeURIComponent(this.data.registerurl);
    //打开注册页面
    if(url && url.startsWith("http")){
      wx.navigateTo({
        url: `../register/register?weburl=${url}`
      });
    }else {//打开其他小程序
      wx.navigateToMiniProgram({
        appId: url,
        extraData: {
        },
        success(res) {
          // 打开成功
        }
      });
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var value = wx.getStorageSync('wygc')
    this.setData({
      registerShow: options.registerurl && options.registerurl.length > 0 ? 'register-show' : '',
      registerurl: decodeURIComponent(options.registerurl),
      url: decodeURIComponent(options.weburl), //获取H5页面传递过来的weburl
      showYwgc: value ? true : false,
      showBtn: !decodeURIComponent(options.weburl).includes('newHomePage')
    });
  },
  /**
   * 用户点击右上角分享***【特别注意这里，配置分享链接一定要给首页链接，要不然别人点进来又是没有返回按钮的哦】***
   */
  onShareAppMessage: function () {
    return {
      title: '泛微移动体验站',
      imageUrl: 'https://enterprise.e-cology.com.cn/cloudstore/release/42cd149d25834ac380e7cede4b55f370/resources/fwszhlogo.png',
      path: '/pages/index/index'
    }
  }
})